#!/bin/bash
:<<EOF

    文件配置函数  获取 对应的表 和 列
    bash  /home/sky/Desktop/shell/chapter12-project_data_market/FILE_CONFIGURATION.sh
    TODO 后续还需要增加  fileMap 的数据

EOF


declare -A fileMap
fileMap["ads_customer_sum_di"]="sett_month,merchant_no,subbranch_code,terminal_no,charge_cycle,fee_accept_flag,product_name,trans_type,package_fee_id,acct_no,card_type,submit_trans_num,submit_amount,trans_num,amount,fee,package_fee,subsidy_fee,init_amount,stages_subsidy_fee,trans_cost,aip_brand_fee,aip_net_income"
fileMap["dim_branch_info"]="merchant_no,belong_branch,expand_branch,maintain_branch,subbranch_code,subbranch_name,subbranch_address,subbranch_contact,subbranch_contact_tel,subbranch_open_time,subbranch_end_time,longitude,latitude,created_date,province,city,busi_district"
fileMap["dim_customer_info"]="merchant_no,merchant_name,mer_shortname,reg_date,change_date,merchant_status,reg_capital,website_url,website_name,mer_property,belong_branch,expand_branch,maintain_branch,sign_subject,division,direct_cor_no,father_no,unionpay_mer_no,source_channel,channel_remark,trans_agent,cooperation_expand,cooperation_recomm,cooperation_profit,cooperation_code,coop_legal_idcard,coop_name,province,city,busi_district,busi_address,mcc_42,industry_1,industry_2,expander,maintener,acct_branch_bank,input_user,open_internal_service_time,cooperation_expander,acct_bank,acct_bank_no,reg_address,finance_person,finance_phone,benef_name,benef_cert_type,benef_cert_no,benef_cert_valid_date,legal_name,legal_idcard,legal_idcard_valid_date,license_name,license_no,license_valid_date,acct_no,credit_code_cert_no,credit_code_cert_valid_date,tax_reg_code,tax_reg_code_valid_date,controller_idcard,controller_idcard_valid_date"
fileMap["dim_prod_info"]="merchant_no,belong_branch,expand_branch,maintain_branch,prodect_type,trans_type,charge_cycle,debit_fee,credit_fee,created_date,update_at,alow_forcard_flag,send_channel_flag,msg_verif_flag,status"
fileMap["dim_term_info"]="merchant_no,belong_branch,expand_branch,maintain_branch,subbranch_code,subbranch_name,subbranch_address,subbranch_contact,subbranch_contact_tel,subbranch_open_time,subbranch_end_time,create_date,update_date,terminal_no,network_type,bind_tel,deposit_amount,service_amount,communicate_fee_cycle,service_charge,service_fee_cycle,open_product,term_status,pos_property,program_version,serial_number,brand,model,gx_remark,term_type"


# LOAD_TABLE=""
# TABLE_COLUMNS=""

function FILE_CONFIGURATION(){


   LOAD_TABLE=""
   TABLE_COLUMNS=""


   local  path=$1
   cd      $path
   local  cur_file=$(ls)

   echo  "正在处理的文件 $cur_file  ......"



  for   key  in    ${!fileMap[@]};
  do

      #如果当前目录包含我配置的  文件key , name就可以下去获取文件对应的配置了;
      if [[ $cur_file  =~   ${key}  ]]; then

          LOAD_TABLE="t_"${key}
          TABLE_COLUMNS=${fileMap[$key]}
          echo  "LOAD_TABLE ==>      ${LOAD_TABLE}"
          echo  "TABLE_COLUMNS ==>   ${TABLE_COLUMNS}"

      fi
  done


}


function test(){
    local path=/dataMarket/local_dev/202406/07/ads_customer_tranx_diff_cost_sum_di_9999610000_101_20240626
    FILE_CONFIGURATION  $path
}



